import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '@/store';
import Header from '../components/Header/header.vue'
import wagesindex from '../view/wagesindex.vue'
// const originalPush = VueRouter.prototype.push
// VueRouter.prototype.push = function push(location) {
//     return originalPush.call(this, location).catch(err => err)
// }

Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    {
      path: '/',
      name: 'loginPage',
      component: resolve => require(['../view/loginPage'], resolve)
    },
    {
      path: '/IndexView',
      name: 'IndexView',
      component: resolve => require(['../view/IndexView'], resolve),
      children:[
        {
          path: '/wagesindex',
          name: 'wagesindex',
          component: resolve => require(['../view/wagesindex'], resolve)
        },
        {
          path: 'xq',
          name: 'xq',
          component: resolve => require(['../view/xq'], resolve)
        },
      ]
    },
    {
      path: '*',
      redirect:'/'
    }
  ],
  //跳转路由置顶
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0 }
}
})
let whiteList = ["/LoginView"]


// router.beforeEach((to, from, next) => {
//   let uid = localStorage.getItem('uid');
//   console.log(store.state.user.uid);
//   // if(!uid){
//   //   console.log(123);
//   //   if(whiteList.indexOf(to.path) !==-1){
//   //     next()
//   //   }else{
//   //     // next({path: '/LoginView'})
//   //     console.log(1236454);
//   //     next()
//   //   }
//   // }
//   // }else{
//   //   console.log("登录成功");
//     // next()
//   // }
// })

export default router



